package io.github.cubelitblade.services;

import io.github.cubelitblade.dao.UserDao;
import io.github.cubelitblade.models.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    private final UserDao userDao;

    @Autowired
    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    public int addUser(User user) {
        return userDao.insert(user);
    }

    public int deleteUser(long id) {
        return userDao.delete(id);
    }

    public User getUser(long id) {
        return userDao.selectById(id);
    }

    public int updateUser(User user) {
        return userDao.update(user);
    }

    public List<User> getAllUsers() {
        return userDao.selectAll();
    }
}
